/*Joseph A. Coll
Cleaning RCV 2 Data
7/23/2025*/

cd "G:\My Drive\Backup 08202022\Working Papers\RCV and Candidate Support\Data and Methods"

*Import Qualtrics data, remove practice runs, save as .dta
	import delimited using "RCV Candidate Support Data.csv", clear
	save "RCV Candidate Support Data Uncleaned.dta", replace
	
	import delimited using "RCV Candidate Support Demos.csv", clear
	rename participantid prolific_pid

	*Age
	fre age
	destring age, ignore("CONSENT_REVOKED") replace
	fre age

	*Gender
	tab sex
	rename sex female_prolific_orig
	gen female_prolific = .
	replace female_prolific = 1 if female_prolific_orig == "Female"
	replace female_prolific = 0 if female_prolific_orig == "Male"
	replace female_prolific = . if female_prolific_orig == "CONSENT_REVOKED"
	label def female 1 "Female" 0 "Male", replace
	label val female_prolific female 
	fre female_prolific

	save "RCV Candidate Support Demos.dta", replace

*Load data
cd "G:\My Drive\Backup 08202022\Working Papers\RCV and Candidate Support\Data and Methods"
	use "RCV Candidate Support Data Uncleaned.dta", clear
	*Remove testing data
	bro startdate enddate prolific_pid exp_cond
	drop in 1/44
	drop if prolific_pid == ""
	sort prolific_pid startdate
	drop if exp_cond == .
	bysort prolific_pid: gen id = _n 
	sum id
	tab id

*Merge prolific demos	
merge 1:1 prolific_pid using "RCV Candidate Support Demos.dta", gen(_mergeS2DEMOS)
bro if _mergeS2DEMOS ==1
bro if _mergeS2DEMOS ==2
drop if _mergeS2DEMOS ==2

*Treatment
fre exp_cond
label def exp_cond 1 "Plurality: Lib-->Cons" 2 "RCV: Lib-->Cons" 3 "RCV Endorse: Lib-->Cons" ///
4 "Plurality: Cons-->Lib" 5 "RCV: Cons-->Lib" 6 "RCV Endorse: Cons-->Lib", replace
label val exp_cond exp_cond
fre exp_cond

gen treatment = .
replace treatment = 1 if exp_cond == 1 | exp_cond ==4 /*Plurality*/
replace treatment = 2 if exp_cond == 2 | exp_cond ==5 /*RCV*/
replace treatment = 3 if exp_cond == 3 | exp_cond ==6 /*RCV Endorse*/
label def treatment 1 "Plurality Comp." 2 "RCV Comp." 3 "RCV Comp. + Endorse", replace
label val treatment treatment
fre treatment

*Ideology
fre ideoss1
gen conservativism = .
replace conservativism = 1 if ideoss1 == "Very liberal"
replace conservativism = 2 if ideoss1 == "Liberal"
replace conservativism = 3 if ideoss1 == "Somewhat liberal"
replace conservativism = 4 if ideoss1 == "True Moderate"
replace conservativism = 5 if ideoss1 == "Somewhat conservative"
replace conservativism = 6 if ideoss1 == "Conservative"
replace conservativism = 7 if ideoss1 == "Very conservative"
label def conservativism 1 "Very liberal" 2 "Liberal" 3 "Somewhat liberal" 4 "Moderate" 5 "Somewhat conservative" 6 "Conservative" 7 "Very Conservative", replace
label val conservativism conservativism
fre conservativism

fre ideos2
replace conservativism = 3 if ideos2 == "Closer to the liberal political viewpoint"
replace conservativism = 5 if ideos2 == "Closer to the conservative political viewpoint"
fre conservativism

tab conservativism
gen liberal = .
replace liberal = 1 if ideoss1 == "Liberal" | ideoss1 == "Somewhat liberal" | ideoss1 == "Very liberal" | ideos2 == "Closer to the liberal political viewpoint"
replace liberal = 0 if liberal != 1
label var liberal Liberal
tab liberal

gen conserv = .
replace conserv = 1 if ideoss1 == "Conservative" | ideoss1 == "Somewhat conservative" | ideoss1 == "Very conservative" | ideos2 == "Closer to the conservative political viewpoint"
replace conserv = 0 if conserv != 1
label var conserv Conservative
tab conserv

gen moderate = .
replace moderate = 1 if ideoss1 == "Moderate" | ideoss1 == "Other" | ideoss1 == "Haven't thought much about it" 
replace moderate = 0 if moderate != 1
label var moderate Moderate
tab moderate

*Traits
label def traits_pos 5 "Extremely well" 4 "Very well" 3 "Somewhat well" 2 "Not too well" 1 "Not at all well", replace

*Conservative
	*Patriotic (Conservative)
	fre traits_c_1
	gen pre_t_pat_cons = .
	replace pre_t_pat_cons = 4 if traits_c_1 == "Extremely well"
	replace pre_t_pat_cons = 3 if traits_c_1 == "Very well"
	replace pre_t_pat_cons = 2 if traits_c_1 == "Somewhat well"
	replace pre_t_pat_cons = 1 if traits_c_1 == "Not too well"
	replace pre_t_pat_cons = 0 if traits_c_1 == "Not at all well"
	label var pre_t_pat_cons "Traits: Patriotic (Conservative)"
	label val pre_t_pat_cons traits_pos
	fre pre_t_pat_cons 

	*Intelligent (Conservative)
	fre traits_c_2
	gen pre_t_int_cons = .
	replace pre_t_int_cons = 4 if traits_c_2 == "Extremely well"
	replace pre_t_int_cons = 3 if traits_c_2 == "Very well"
	replace pre_t_int_cons = 2 if traits_c_2 == "Somewhat well"
	replace pre_t_int_cons = 1 if traits_c_2 == "Not too well"
	replace pre_t_int_cons = 0 if traits_c_2 == "Not at all well"
	label var pre_t_int_cons "Traits: Intelligent (Conservative)"
	label val pre_t_int_cons traits_pos
	fre pre_t_int_cons 

	*Honest (Conservative)
	fre traits_c_3
	gen pre_t_hon_cons = .
	replace pre_t_hon_cons = 4 if traits_c_3 == "Extremely well"
	replace pre_t_hon_cons = 3 if traits_c_3 == "Very well"
	replace pre_t_hon_cons = 2 if traits_c_3 == "Somewhat well"
	replace pre_t_hon_cons = 1 if traits_c_3 == "Not too well"
	replace pre_t_hon_cons = 0 if traits_c_3 == "Not at all well"
	label var pre_t_hon_cons "Traits: Honest (Conservative)"
	label val pre_t_hon_cons traits_pos
	fre pre_t_hon_cons 

	*Open-Minded (Conservative)
	fre traits_c_4
	gen pre_t_opm_cons = .
	replace pre_t_opm_cons = 4 if traits_c_4 == "Extremely well"
	replace pre_t_opm_cons = 3 if traits_c_4 == "Very well"
	replace pre_t_opm_cons = 5 if traits_c_4 == "Somewhat well"
	replace pre_t_opm_cons = 1 if traits_c_4 == "Not too well"
	replace pre_t_opm_cons = 0 if traits_c_4 == "Not at all well"
	label var pre_t_opm_cons "Traits: Open-Minded (Conservative)"
	label val pre_t_opm_cons traits_pos
	fre pre_t_opm_cons 

	*Generous (Conservative)
	fre traits_c_5
	gen pre_t_gen_cons = .
	replace pre_t_gen_cons = 4 if traits_c_5 == "Extremely well"
	replace pre_t_gen_cons = 3 if traits_c_5 == "Very well"
	replace pre_t_gen_cons = 5 if traits_c_5 == "Somewhat well"
	replace pre_t_gen_cons = 1 if traits_c_5 == "Not too well"
	replace pre_t_gen_cons = 0 if traits_c_5 == "Not at all well"
	label var pre_t_gen_cons "Traits: Generous (Conservative)"
	label val pre_t_gen_cons traits_pos
	fre pre_t_gen_cons 

	*Hypocritical (Conservative)
	fre traits_c_6
	gen pre_t_hyp_cons = .
	replace pre_t_hyp_cons = 1 if traits_c_6 == "Extremely well"
	replace pre_t_hyp_cons = 2 if traits_c_6 == "Very well"
	replace pre_t_hyp_cons = 3 if traits_c_6 == "Somewhat well"
	replace pre_t_hyp_cons = 4 if traits_c_6 == "Not too well"
	replace pre_t_hyp_cons = 5 if traits_c_6 == "Not at all well"
	label var pre_t_hyp_cons "Traits: Hypocritical (Conservative)"
	label val pre_t_hyp_cons traits_pos
	fre pre_t_hyp_cons 

	*Selfish (Conservative)
	fre traits_c_7
	gen pre_t_slf_cons = .
	replace pre_t_slf_cons = 1 if traits_c_7 == "Extremely well"
	replace pre_t_slf_cons = 2 if traits_c_7 == "Very well"
	replace pre_t_slf_cons = 3 if traits_c_7 == "Somewhat well"
	replace pre_t_slf_cons = 4 if traits_c_7 == "Not too well"
	replace pre_t_slf_cons = 5 if traits_c_7 == "Not at all well"
	label var pre_t_slf_cons "Traits: Selfish (Conservative)"
	label val pre_t_slf_cons traits_pos
	fre pre_t_slf_cons 

	*Mean (Conservative)
	fre traits_c_8
	gen pre_t_men_cons = .
	replace pre_t_men_cons = 1 if traits_c_8 == "Extremely well"
	replace pre_t_men_cons = 2 if traits_c_8 == "Very well"
	replace pre_t_men_cons = 3 if traits_c_8 == "Somewhat well"
	replace pre_t_men_cons = 4 if traits_c_8 == "Not too well"
	replace pre_t_men_cons = 5 if traits_c_8 == "Not at all well"
	label var pre_t_men_cons "Traits: Mean (Conservative)"
	label val pre_t_men_cons traits_pos
	fre pre_t_men_cons 

*Liberal
	*Patriotic (Liberal)
	fre traits_l_1
	gen pre_t_pat_lib = .
	replace pre_t_pat_lib = 4 if traits_l_1 == "Extremely well"
	replace pre_t_pat_lib = 3 if traits_l_1 == "Very well"
	replace pre_t_pat_lib = 2 if traits_l_1 == "Somewhat well"
	replace pre_t_pat_lib = 1 if traits_l_1 == "Not too well"
	replace pre_t_pat_lib = 0 if traits_l_1 == "Not at all well"
	label var pre_t_pat_lib "Traits: Patriotic (Liberal)"
	label val pre_t_pat_lib traits_pos
	fre pre_t_pat_lib 

	*Intelligent (Liberal)
	fre traits_l_2
	gen pre_t_int_lib = .
	replace pre_t_int_lib = 4 if traits_l_2 == "Extremely well"
	replace pre_t_int_lib = 3 if traits_l_2 == "Very well"
	replace pre_t_int_lib = 5 if traits_l_2 == "Somewhat well"
	replace pre_t_int_lib = 1 if traits_l_2 == "Not too well"
	replace pre_t_int_lib = 0 if traits_l_2 == "Not at all well"
	label var pre_t_int_lib "Traits: Intelligent (Liberal)"
	label val pre_t_int_lib traits_pos
	fre pre_t_int_lib 

	*Honest (Liberal)
	fre traits_l_3
	gen pre_t_hon_lib = .
	replace pre_t_hon_lib = 4 if traits_l_3 == "Extremely well"
	replace pre_t_hon_lib = 3 if traits_l_3 == "Very well"
	replace pre_t_hon_lib = 2 if traits_l_3 == "Somewhat well"
	replace pre_t_hon_lib = 1 if traits_l_3 == "Not too well"
	replace pre_t_hon_lib = 0 if traits_l_3 == "Not at all well"
	label var pre_t_hon_lib "Traits: Honest (Liberal)"
	label val pre_t_hon_lib traits_pos
	fre pre_t_hon_lib 

	*Open-Minded (Liberal)
	fre traits_l_4
	gen pre_t_opm_lib = .
	replace pre_t_opm_lib = 4 if traits_l_4 == "Extremely well"
	replace pre_t_opm_lib = 3 if traits_l_4 == "Very well"
	replace pre_t_opm_lib = 2 if traits_l_4 == "Somewhat well"
	replace pre_t_opm_lib = 1 if traits_l_4 == "Not too well"
	replace pre_t_opm_lib = 0 if traits_l_4 == "Not at all well"
	label var pre_t_opm_lib "Traits: Open-Minded (Liberal)"
	label val pre_t_opm_lib traits_pos
	fre pre_t_opm_lib 

	*Generous (Liberal)
	fre traits_l_5
	gen pre_t_gen_lib = .
	replace pre_t_gen_lib = 4 if traits_l_5 == "Extremely well"
	replace pre_t_gen_lib = 3 if traits_l_5 == "Very well"
	replace pre_t_gen_lib = 2 if traits_l_5 == "Somewhat well"
	replace pre_t_gen_lib = 1 if traits_l_5 == "Not too well"
	replace pre_t_gen_lib = 0 if traits_l_5 == "Not at all well"
	label var pre_t_gen_lib "Traits: Generous (Liberal)"
	label val pre_t_gen_lib traits_pos
	fre pre_t_gen_lib 

	*Hypocritical (Liberal)
	fre traits_l_6
	gen pre_t_hyp_lib = .
	replace pre_t_hyp_lib = 0 if traits_l_6 == "Extremely well"
	replace pre_t_hyp_lib = 1 if traits_l_6 == "Very well"
	replace pre_t_hyp_lib = 2 if traits_l_6 == "Somewhat well"
	replace pre_t_hyp_lib = 3 if traits_l_6 == "Not too well"
	replace pre_t_hyp_lib = 4 if traits_l_6 == "Not at all well"
	label var pre_t_hyp_lib "Traits: Hypocritical (Liberal)"
	label val pre_t_hyp_lib traits_pos
	fre pre_t_hyp_lib 

	*Selfish (Liberal)
	fre traits_l_7
	gen pre_t_slf_lib = .
	replace pre_t_slf_lib = 0 if traits_l_7 == "Extremely well"
	replace pre_t_slf_lib = 1 if traits_l_7 == "Very well"
	replace pre_t_slf_lib = 2 if traits_l_7 == "Somewhat well"
	replace pre_t_slf_lib = 3 if traits_l_7 == "Not too well"
	replace pre_t_slf_lib = 4 if traits_l_7 == "Not at all well"
	label var pre_t_slf_lib "Traits: Selfish (Liberal)"
	label val pre_t_slf_lib traits_pos
	fre pre_t_slf_lib 

	*Mean (Liberal)
	fre traits_l_8
	gen pre_t_men_lib = .
	replace pre_t_men_lib = 0 if traits_l_8 == "Extremely well"
	replace pre_t_men_lib = 1 if traits_l_8 == "Very well"
	replace pre_t_men_lib = 2 if traits_l_8 == "Somewhat well"
	replace pre_t_men_lib = 3 if traits_l_8 == "Not too well"
	replace pre_t_men_lib = 4 if traits_l_8 == "Not at all well"
	label var pre_t_men_lib "Traits: Mean (Liberal)"
	label val pre_t_men_lib traits_pos
	fre pre_t_men_lib 

sum pre_t_pat_cons pre_t_int_cons pre_t_hon_cons pre_t_opm_cons pre_t_gen_cons pre_t_hyp_cons pre_t_slf_cons pre_t_men_cons pre_t_pat_lib pre_t_int_lib pre_t_hon_lib pre_t_opm_lib pre_t_gen_lib pre_t_hyp_lib pre_t_slf_lib pre_t_men_lib
local vars pre_t_pat_cons pre_t_int_cons pre_t_hon_cons pre_t_opm_cons pre_t_gen_cons pre_t_hyp_cons pre_t_slf_cons pre_t_men_cons pre_t_pat_lib pre_t_int_lib pre_t_hon_lib pre_t_opm_lib pre_t_gen_lib pre_t_hyp_lib pre_t_slf_lib pre_t_men_lib
foreach x of local vars {
clonevar `x'_bin = `x'
replace `x'_bin = (`x'_bin)/4
}
sum pre_t_pat_cons_bin pre_t_int_cons_bin pre_t_hon_cons_bin pre_t_opm_cons_bin pre_t_gen_cons_bin pre_t_hyp_cons_bin pre_t_slf_cons_bin pre_t_men_cons_bin pre_t_pat_lib_bin pre_t_int_lib_bin pre_t_hon_lib_bin pre_t_opm_lib_bin pre_t_gen_lib_bin pre_t_hyp_lib_bin pre_t_slf_lib_bin pre_t_men_lib_bin

*Pre-FT
	*Conservative
	fre ft_1
	gen pre_ft_cons = ft_1
	replace  pre_ft_cons = pre_ft_cons /100
	label var pre_ft_cons "FT: Conservatives"
	fre pre_ft_cons 
	
	*Liberal
	fre ft_2
	gen pre_ft_lib = ft_2
	replace  pre_ft_lib = pre_ft_lib /100
	label var pre_ft_lib "FT: Liberals"
	fre pre_ft_lib 

*Age
tab yearborn_1
replace yearborn_1 = . if yearborn_1 <1943 | yearborn_1 >2006
rename age age_original
gen age = 2025-yearborn_1
tab age

replace age = age_original if age == .
replace age = 43 if age == .
label var age Age
sum age
fre age

*Gender
fre gender
gen female = 1 if gender == "Female"
replace female = 0 if gender != "Female"
label def female 1 "Female" 0 "Other", replace
label val female female
label var female Female
fre female

*Race
fre ethnicitysimplified
gen white = .
replace white =1 if ethnicitysimplified == "White"
replace white =0 if ethnicitysimplified != "White"
label var white White
fre white

*Educ
fre education
fre education, nol
gen bach_above = .
replace bach_above = 1 if education == "4-year college degree (e.g., Bachelor's degree)"
replace bach_above = 1 if education == "Post-graduate degree (e.g., Masters, Doctorate)"
replace bach_above = 0 if education != "4-year college degree (e.g., Bachelor's degree)"
label var bach_above "Bach./Adv. Degree"
fre bach_above

gen educ = .
replace educ = 1 if education == "Did not graduate from high school" | education == "High school graduate or equivalent"
replace educ = 2 if education == "Some college, but no degree (e.g., still attending college or dropped out before finishing)"
replace educ = 3 if education == "2-year college degree (e.g., Associate's degree)"
replace educ = 4 if education == "4-year college degree (e.g., Bachelor's degree)"
replace educ = 5 if education == "Post-graduate degree (e.g., Masters, Doctorate)"
label var educ Education
fre educ 

*Partisanship
fre pid
fre pid_rep
fre pid_dem
fre pid_ind

gen dem_wlean = .
replace dem_wlean = 1 if pid == "Democrat" | pid_ind == "Closer to the Democratic party"
replace dem_wlean = 0 if dem_wlean  != 1
label var dem_wlean "Demcorat"
fre dem_wlean

gen rep_wlean = .
replace rep_wlean = 1 if pid == "Republican" | pid_ind == "Closer to the Republican party"
replace rep_wlean = 0 if rep_wlean  != 1
label var rep_wlean "Republican"
fre rep_wlean

gen ind_nolean = .
replace ind_nolean = 1 if pid_ind == "Neither"
replace ind_nolean = 0 if ind_nolean  != 1
label var ind_nolean "Independent"
fre ind_nolean

gen pid_scale3 = . 
replace pid_scale3 = 1 if dem_wlean ==1 
replace pid_scale3 = 2 if ind_nolean ==1 
replace pid_scale3 = 3 if rep_wlean ==1 
fre pid_scale3

*Political interest
fre poli_int
rename poli_int poli_int_orig
gen poli_int = .
replace poli_int = 1 if poli_int_orig == "Hardly at all"
replace poli_int = 2 if poli_int_orig == "Only now and then"
replace poli_int = 3 if poli_int_orig == "Some of the time"
replace poli_int = 4 if poli_int_orig == "Most of the time"
label def poli_int 1 "Never" 2 "Rarely" 3 "Sometimes" 4 "Often", replace 
label val poli_int poli_int 
label var poli_int "Political Interest"
fre poli_int 

gen poli_int_01 = .
replace poli_int_01 = (poli_int-1)/3
label var poli_int_01 "Political Interest"
fre poli_int_01 

*News Trust
fre trust_news
rename trust_news trust_news_orig
gen news_trust = .
replace news_trust = 1 if trust_news_orig == "Never"
replace news_trust = 2 if trust_news_orig == "Rarely"
replace news_trust = 3 if trust_news_orig == "Sometimes"
replace news_trust = 4 if trust_news_orig == "Often"
replace news_trust = 5 if trust_news_orig == "Always"
label def news_trust 1 "Never" 2 "Rarely" 3 "Sometimes" 4 "Often" 5 "Always", replace 
label val news_trust news_trust 
label var news_trust "News Trust"
fre news_trust 

gen news_trust_01 = .
replace news_trust_01 = (news_trust-1)/4
label var news_trust_01 "News Trust"
fre news_trust_01 

*MVC
label def mvc_correct 1 "Correct" 0 "Incorrect", replace
	
	*Topic
	fre mvc_topic 
	gen mvc_topic_correct = .
	replace mvc_topic_correct = 1 if mvc_topic == "Event Licensing in stadiums"
	replace mvc_topic_correct = 0 if mvc_topic != "Event Licensing in stadiums"
	label val mvc_topic_correct mvc_correct
	label var mvc_topic_correct "MVC: Topic"
	fre mvc_topic_correct
	
	*Goal
	fre mvc_goal 
	gen mvc_goal_correct = .
	replace mvc_goal_correct = 1 if mvc_goal == "A single license will cover all events occurring in a stadium"
	replace mvc_goal_correct = 0 if mvc_goal != "A single license will cover all events occurring in a stadium"
	label val mvc_goal_correct mvc_correct
	label var mvc_goal_correct "MVC: Goal"
	fre mvc_goal_correct

	*Effect
	fre mvc_effect 
	gen mvc_effect_correct = .
	replace mvc_effect_correct = 1 if mvc_effect == "There may be a special hearing held by lawmakers"
	replace mvc_effect_correct = 0 if mvc_effect != "There may be a special hearing held by lawmakers"
	label val mvc_effect_correct mvc_correct
	label var mvc_effect_correct "MVC: Effect"
	fre mvc_effect_correct

	*Total
	gen mvc_correct_total = .
	replace mvc_correct_total = mvc_topic_correct+ mvc_goal_correct + mvc_effect_correct
	label var mvc_correct_total "MVC Score"
	fre mvc_correct_total
	
*Next buttons
local vars mvc_next plc_next rlc_next relc_next pcl_next rcl_next recl_next
foreach x of local vars {
	fre `x'
	gen `x'_clicked = .
	replace `x'_clicked = 1 if `x' == "Next"
	replace `x'_clicked = 0 if `x' != "Next"
	}
 
fre exp_cond
replace plc_next_clicked = . if exp_cond  != 1
replace rlc_next_clicked = . if exp_cond  != 2
replace relc_next_clicked = . if exp_cond  != 3
replace pcl_next_clicked = . if exp_cond  != 4
replace rcl_next_clicked = . if exp_cond  != 5
replace recl_next_clicked = . if exp_cond  != 6

local vars plc_next_clicked rlc_next_clicked relc_next_clicked pcl_next_clicked rcl_next_clicked recl_next_clicked
foreach x of local vars {
	fre `x'
	}
 
*FMC
label def fmc_correct 1 "Correct" 0 "Incorrect", replace
fre exp_cond

	*Ideology
	fre fmc_ideo
	gen fmc_ideo_correct = .
	replace fmc_ideo_correct = 1 if fmc_ideo == "Conservative" & exp_cond >3
	replace fmc_ideo_correct = 1 if fmc_ideo == "Liberal" & exp_cond <4
	
	replace fmc_ideo_correct = 0 if fmc_ideo == "Conservative" & exp_cond <4
	replace fmc_ideo_correct = 0 if fmc_ideo == "Liberal" & exp_cond >3
	replace fmc_ideo_correct = 0 if fmc_ideo == "Independent"
	replace fmc_ideo_correct = 0 if fmc_ideo == "Moderate"
 	replace fmc_ideo_correct = 0 if fmc_ideo == "Communist"
	replace fmc_ideo_correct = 0 if fmc_ideo == ""
   
	label val fmc_ideo_correct fmc_correct
	label var fmc_ideo_correct "FMC: Candidate Ideology"
	fre fmc_ideo_correct
	
	*Election Type
	fre fmc_elect
	gen fmc_elect_correct = .
	replace fmc_elect_correct = 1 if fmc_elect == "Plurality election" & exp_cond ==1
	replace fmc_elect_correct = 1 if fmc_elect == "Plurality election" & exp_cond ==4
	
	replace fmc_elect_correct = 1 if fmc_elect == "Ranked choice voting election" & exp_cond ==2
	replace fmc_elect_correct = 1 if fmc_elect == "Ranked choice voting election" & exp_cond ==3
	replace fmc_elect_correct = 1 if fmc_elect == "Ranked choice voting election" & exp_cond ==5
	replace fmc_elect_correct = 1 if fmc_elect == "Ranked choice voting election" & exp_cond ==6	
	
	replace fmc_elect_correct = 0 if fmc_elect == "Plurality election" & exp_cond ==2
	replace fmc_elect_correct = 0 if fmc_elect == "Plurality election" & exp_cond ==3
	replace fmc_elect_correct = 0 if fmc_elect == "Plurality election" & exp_cond ==5
	replace fmc_elect_correct = 0 if fmc_elect == "Plurality election" & exp_cond ==6	
	
	replace fmc_elect_correct = 0 if fmc_elect == "Ranked choice voting election" & exp_cond ==1
	replace fmc_elect_correct = 0 if fmc_elect == "Ranked choice voting election" & exp_cond ==4
	
	replace fmc_elect_correct = 0 if fmc_elect == "Proportional representation election"
	replace fmc_elect_correct = 0 if fmc_elect == "Mixed-member district election"
	replace fmc_elect_correct = 0 if fmc_elect == "At-large election"
	replace fmc_elect_correct = 0 if fmc_elect == ""
	
	label val fmc_elect_correct fmc_correct
	label var fmc_elect_correct "FMC: Election Type"
	fre fmc_elect_correct
	
	*Story
	fre fmc_story
	gen fmc_story_correct = .
	replace fmc_story_correct = 1 if fmc_story == "Complimented the other candidate" & exp_cond == 1 
	replace fmc_story_correct = 1 if fmc_story == "Complimented the other candidate" & exp_cond == 2 
	replace fmc_story_correct = 1 if fmc_story == "Complimented the other candidate" & exp_cond == 4 
	replace fmc_story_correct = 1 if fmc_story == "Complimented the other candidate" & exp_cond == 5 

	replace fmc_story_correct = 1 if fmc_story == "Endorsed the other candidate" & exp_cond == 3 
	replace fmc_story_correct = 1 if fmc_story == "Endorsed the other candidate" & exp_cond == 6 

	replace fmc_story_correct = 0 if fmc_story == "Endorsed the other candidate" & exp_cond == 1 
	replace fmc_story_correct = 0 if fmc_story == "Endorsed the other candidate" & exp_cond == 2 
	replace fmc_story_correct = 0 if fmc_story == "Endorsed the other candidate" & exp_cond == 4 
	replace fmc_story_correct = 0 if fmc_story == "Endorsed the other candidate" & exp_cond == 5 

	replace fmc_story_correct = 0 if fmc_story == "Complimented the other candidate" & exp_cond == 3 
	replace fmc_story_correct = 0 if fmc_story == "Complimented the other candidate" & exp_cond == 6 

	replace fmc_story_correct = 0 if fmc_story == "Insulted the other candidate"  
	replace fmc_story_correct = 0 if fmc_story == "Assaulted the other candidate"  
	replace fmc_story_correct = 0 if fmc_story == "Accused the other candidate of violating campaign finance laws"  
	replace fmc_story_correct = 0 if fmc_story == ""
	
	label val fmc_story_correct fmc_correct
	label var fmc_story_correct "FMC: Candidate Interaction"
	fre fmc_story_correct

	*Total
	gen fmc_correct_total = .
	replace fmc_correct_total = fmc_ideo_correct + fmc_elect_correct + fmc_story_correct
	label var fmc_correct_total "FMC Score"
	fre fmc_correct_total
	
*Post-FT
	*Conservative
	fre post_ap_ft_2
	gen post_ft_cons = post_ap_ft_2
	replace  post_ft_cons = post_ft_cons /100
	label var post_ft_cons "FT: Conservatives"
	fre post_ft_cons 
	
	*Liberal
	fre post_ap_ft_1
	gen post_ft_lib = post_ap_ft_1
	replace  post_ft_lib = post_ft_lib /100
	label var post_ft_lib "FT: Liberals"
	fre post_ft_lib 

*Traits
*Conservative
	*Patriotic (Conservative)
	fre post_ap_trait_r_1
	gen post_t_pat_cons = .
	replace post_t_pat_cons = 4 if post_ap_trait_r_1 == "Extremely well"
	replace post_t_pat_cons = 3 if post_ap_trait_r_1 == "Very well"
	replace post_t_pat_cons = 2 if post_ap_trait_r_1 == "Somewhat well"
	replace post_t_pat_cons = 1 if post_ap_trait_r_1 == "Not too well"
	replace post_t_pat_cons = 0 if post_ap_trait_r_1 == "Not at all well"
	label var post_t_pat_cons "Traits: Patriotic (Conservative)"
	label val post_t_pat_cons traits_pos
	fre post_t_pat_cons 

	*Intelligent (Conservative)
	fre post_ap_trait_r_2
	gen post_t_int_cons = .
	replace post_t_int_cons = 4 if post_ap_trait_r_2 == "Extremely well"
	replace post_t_int_cons = 3 if post_ap_trait_r_2 == "Very well"
	replace post_t_int_cons = 2 if post_ap_trait_r_2 == "Somewhat well"
	replace post_t_int_cons = 1 if post_ap_trait_r_2 == "Not too well"
	replace post_t_int_cons = 0 if post_ap_trait_r_2 == "Not at all well"
	label var post_t_int_cons "Traits: Intelligent (Conservative)"
	label val post_t_int_cons traits_pos
	fre post_t_int_cons 

	*Honest (Conservative)
	fre post_ap_trait_r_3
	gen post_t_hon_cons = .
	replace post_t_hon_cons = 4 if post_ap_trait_r_3 == "Extremely well"
	replace post_t_hon_cons = 3 if post_ap_trait_r_3 == "Very well"
	replace post_t_hon_cons = 2 if post_ap_trait_r_3 == "Somewhat well"
	replace post_t_hon_cons = 1 if post_ap_trait_r_3 == "Not too well"
	replace post_t_hon_cons = 0 if post_ap_trait_r_3 == "Not at all well"
	label var post_t_hon_cons "Traits: Honest (Conservative)"
	label val post_t_hon_cons traits_pos
	fre post_t_hon_cons 

	*Open-Minded (Conservative)
	fre post_ap_trait_r_4
	gen post_t_opm_cons = .
	replace post_t_opm_cons = 4 if post_ap_trait_r_4 == "Extremely well"
	replace post_t_opm_cons = 3 if post_ap_trait_r_4 == "Very well"
	replace post_t_opm_cons = 2 if post_ap_trait_r_4 == "Somewhat well"
	replace post_t_opm_cons = 1 if post_ap_trait_r_4 == "Not too well"
	replace post_t_opm_cons = 0 if post_ap_trait_r_4 == "Not at all well"
	label var post_t_opm_cons "Traits: Open-Minded (Conservative)"
	label val post_t_opm_cons traits_pos
	fre post_t_opm_cons 

	*Generous (Conservative)
	fre post_ap_trait_r_5
	gen post_t_gen_cons = .
	replace post_t_gen_cons = 4 if post_ap_trait_r_5 == "Extremely well"
	replace post_t_gen_cons = 3 if post_ap_trait_r_5 == "Very well"
	replace post_t_gen_cons = 2 if post_ap_trait_r_5 == "Somewhat well"
	replace post_t_gen_cons = 1 if post_ap_trait_r_5 == "Not too well"
	replace post_t_gen_cons = 0 if post_ap_trait_r_5 == "Not at all well"
	label var post_t_gen_cons "Traits: Generous (Conservative)"
	label val post_t_gen_cons traits_pos
	fre post_t_gen_cons 

	*Hypocritical (Conservative)
	fre post_ap_trait_r_6
	gen post_t_hyp_cons = .
	replace post_t_hyp_cons = 0 if post_ap_trait_r_6 == "Extremely well"
	replace post_t_hyp_cons = 1 if post_ap_trait_r_6 == "Very well"
	replace post_t_hyp_cons = 2 if post_ap_trait_r_6 == "Somewhat well"
	replace post_t_hyp_cons = 3 if post_ap_trait_r_6 == "Not too well"
	replace post_t_hyp_cons = 4 if post_ap_trait_r_6 == "Not at all well"
	label var post_t_hyp_cons "Traits: Hypocritical (Conservative)"
	label val post_t_hyp_cons traits_pos
	fre post_t_hyp_cons 

	*Selfish (Conservative)
	fre post_ap_trait_r_7
	gen post_t_slf_cons = .
	replace post_t_slf_cons = 0 if post_ap_trait_r_7 == "Extremely well"
	replace post_t_slf_cons = 1 if post_ap_trait_r_7 == "Very well"
	replace post_t_slf_cons = 2 if post_ap_trait_r_7 == "Somewhat well"
	replace post_t_slf_cons = 3 if post_ap_trait_r_7 == "Not too well"
	replace post_t_slf_cons = 4 if post_ap_trait_r_7 == "Not at all well"
	label var post_t_slf_cons "Traits: Selfish (Conservative)"
	label val post_t_slf_cons traits_pos
	fre post_t_slf_cons 

	*Mean (Conservative)
	fre post_ap_trait_r_8
	gen post_t_men_cons = .
	replace post_t_men_cons = 0 if post_ap_trait_r_8 == "Extremely well"
	replace post_t_men_cons = 1 if post_ap_trait_r_8 == "Very well"
	replace post_t_men_cons = 2 if post_ap_trait_r_8 == "Somewhat well"
	replace post_t_men_cons = 3 if post_ap_trait_r_8 == "Not too well"
	replace post_t_men_cons = 4 if post_ap_trait_r_8 == "Not at all well"
	label var post_t_men_cons "Traits: Mean (Conservative)"
	label val post_t_men_cons traits_pos
	fre post_t_men_cons 

*Liberal
	*Patriotic (Liberal)
	fre post_ap_trait_l_1
	gen post_t_pat_lib = .
	replace post_t_pat_lib = 4 if post_ap_trait_l_1 == "Extremely well"
	replace post_t_pat_lib = 3 if post_ap_trait_l_1 == "Very well"
	replace post_t_pat_lib = 2 if post_ap_trait_l_1 == "Somewhat well"
	replace post_t_pat_lib = 1 if post_ap_trait_l_1 == "Not too well"
	replace post_t_pat_lib = 0 if post_ap_trait_l_1 == "Not at all well"
	label var post_t_pat_lib "Traits: Patriotic (Liberal)"
	label val post_t_pat_lib traits_pos
	fre post_t_pat_lib 

	*Intelligent (Liberal)
	fre post_ap_trait_l_2
	gen post_t_int_lib = .
	replace post_t_int_lib = 4 if post_ap_trait_l_2 == "Extremely well"
	replace post_t_int_lib = 3 if post_ap_trait_l_2 == "Very well"
	replace post_t_int_lib = 2 if post_ap_trait_l_2 == "Somewhat well"
	replace post_t_int_lib = 1 if post_ap_trait_l_2 == "Not too well"
	replace post_t_int_lib = 0 if post_ap_trait_l_2 == "Not at all well"
	label var post_t_int_lib "Traits: Intelligent (Liberal)"
	label val post_t_int_lib traits_pos
	fre post_t_int_lib 

	*Honest (Liberal)
	fre post_ap_trait_l_3
	gen post_t_hon_lib = .
	replace post_t_hon_lib = 4 if post_ap_trait_l_3 == "Extremely well"
	replace post_t_hon_lib = 3 if post_ap_trait_l_3 == "Very well"
	replace post_t_hon_lib = 2 if post_ap_trait_l_3 == "Somewhat well"
	replace post_t_hon_lib = 1 if post_ap_trait_l_3 == "Not too well"
	replace post_t_hon_lib = 0 if post_ap_trait_l_3 == "Not at all well"
	label var post_t_hon_lib "Traits: Honest (Liberal)"
	label val post_t_hon_lib traits_pos
	fre post_t_hon_lib 

	*Open-Minded (Liberal)
	fre post_ap_trait_l_4
	gen post_t_opm_lib = .
	replace post_t_opm_lib = 4 if post_ap_trait_l_4 == "Extremely well"
	replace post_t_opm_lib = 3 if post_ap_trait_l_4 == "Very well"
	replace post_t_opm_lib = 2 if post_ap_trait_l_4 == "Somewhat well"
	replace post_t_opm_lib = 1 if post_ap_trait_l_4 == "Not too well"
	replace post_t_opm_lib = 0 if post_ap_trait_l_4 == "Not at all well"
	label var post_t_opm_lib "Traits: Open-Minded (Liberal)"
	label val post_t_opm_lib traits_pos
	fre post_t_opm_lib 

	*Generous (Liberal)
	fre post_ap_trait_l_5
	gen post_t_gen_lib = .
	replace post_t_gen_lib = 4 if post_ap_trait_l_5 == "Extremely well"
	replace post_t_gen_lib = 3 if post_ap_trait_l_5 == "Very well"
	replace post_t_gen_lib = 2 if post_ap_trait_l_5 == "Somewhat well"
	replace post_t_gen_lib = 1 if post_ap_trait_l_5 == "Not too well"
	replace post_t_gen_lib = 0 if post_ap_trait_l_5 == "Not at all well"
	label var post_t_gen_lib "Traits: Generous (Liberal)"
	label val post_t_gen_lib traits_pos
	fre post_t_gen_lib 

	*Hypocritical (Liberal)
	fre post_ap_trait_l_6
	gen post_t_hyp_lib = .
	replace post_t_hyp_lib = 0 if post_ap_trait_l_6 == "Extremely well"
	replace post_t_hyp_lib = 1 if post_ap_trait_l_6 == "Very well"
	replace post_t_hyp_lib = 2 if post_ap_trait_l_6 == "Somewhat well"
	replace post_t_hyp_lib = 3 if post_ap_trait_l_6 == "Not too well"
	replace post_t_hyp_lib = 4 if post_ap_trait_l_6 == "Not at all well"
	label var post_t_hyp_lib "Traits: Hypocritical (Liberal)"
	label val post_t_hyp_lib traits_pos
	fre post_t_hyp_lib 

	*Selfish (Liberal)
	fre post_ap_trait_l_7
	gen post_t_slf_lib = .
	replace post_t_slf_lib = 0 if post_ap_trait_l_7 == "Extremely well"
	replace post_t_slf_lib = 1 if post_ap_trait_l_7 == "Very well"
	replace post_t_slf_lib = 2 if post_ap_trait_l_7 == "Somewhat well"
	replace post_t_slf_lib = 3 if post_ap_trait_l_7 == "Not too well"
	replace post_t_slf_lib = 4 if post_ap_trait_l_7 == "Not at all well"
	label var post_t_slf_lib "Traits: Selfish (Liberal)"
	label val post_t_slf_lib traits_pos
	fre post_t_slf_lib 

	*Mean (Liberal)
	fre post_ap_trait_l_8
	gen post_t_men_lib = .
	replace post_t_men_lib = 0 if post_ap_trait_l_8 == "Extremely well"
	replace post_t_men_lib = 1 if post_ap_trait_l_8 == "Very well"
	replace post_t_men_lib = 2 if post_ap_trait_l_8 == "Somewhat well"
	replace post_t_men_lib = 3 if post_ap_trait_l_8 == "Not too well"
	replace post_t_men_lib = 4 if post_ap_trait_l_8 == "Not at all well"
	label var post_t_men_lib "Traits: Mean (Liberal)"
	label val post_t_men_lib traits_pos
	fre post_t_men_lib 

sum post_t_pat_cons post_t_int_cons post_t_hon_cons post_t_opm_cons post_t_gen_cons post_t_hyp_cons post_t_slf_cons post_t_men_cons post_t_pat_lib post_t_int_lib post_t_hon_lib post_t_opm_lib post_t_gen_lib post_t_hyp_lib post_t_slf_lib post_t_men_lib
local vars post_t_pat_cons post_t_int_cons post_t_hon_cons post_t_opm_cons post_t_gen_cons post_t_hyp_cons post_t_slf_cons post_t_men_cons post_t_pat_lib post_t_int_lib post_t_hon_lib post_t_opm_lib post_t_gen_lib post_t_hyp_lib post_t_slf_lib post_t_men_lib
foreach x of local vars {
clonevar `x'_bin = `x'
replace `x'_bin = (`x'_bin)/4
}


sum post_t_pat_cons_bin post_t_int_cons_bin post_t_hon_cons_bin post_t_opm_cons_bin post_t_gen_cons_bin post_t_hyp_cons_bin post_t_slf_cons_bin post_t_men_cons_bin post_t_pat_lib_bin post_t_int_lib_bin post_t_hon_lib_bin post_t_opm_lib_bin post_t_gen_lib_bin post_t_hyp_lib_bin post_t_slf_lib_bin post_t_men_lib_bin

*Support for election systems
label def support 1 "Strongly oppose" 2 "Oppose" 3 "Somewhat oppose" 4 "Neither" 5 "Somewhat support" 6 "Support" 7 "Strongly support", replace

	*Plurality
	fre rcv_pros_1 
	gen support_plurality = .
	replace support_plurality = 1 if rcv_pros_1 == "Strongly oppose"
	replace support_plurality = 2 if rcv_pros_1 == "Oppose"
	replace support_plurality = 3 if rcv_pros_1 == "Somewhat oppose"
	replace support_plurality = 4 if rcv_pros_1 == "Neither support nor oppose"
	replace support_plurality = 5 if rcv_pros_1 == "Somewhat support"
	replace support_plurality = 6 if rcv_pros_1 == "Support"
	replace support_plurality = 7 if rcv_pros_1 == "Strongly support"
	label val support_plurality support
	label var support_plurality "Plurality Support"
	fre support_plurality

	gen support_plurality01 = (support_plurality -1)/6
	label var support_plurality01 "Plurality Support"
	sum support_plurality01 
	
	*RCV
	fre rcv_pros_2 
	gen support_rcv = .
	replace support_rcv = 1 if rcv_pros_2 == "Strongly oppose"
	replace support_rcv = 2 if rcv_pros_2 == "Oppose"
	replace support_rcv = 3 if rcv_pros_2 == "Somewhat oppose"
	replace support_rcv = 4 if rcv_pros_2 == "Neither support nor oppose"
	replace support_rcv = 5 if rcv_pros_2 == "Somewhat support"
	replace support_rcv = 6 if rcv_pros_2 == "Support"
	replace support_rcv = 7 if rcv_pros_2 == "Strongly support"
	label val support_rcv support
	label var support_rcv "RCV Support"
	fre support_rcv

	gen support_rcv_01 = (support_rcv -1)/6
	label var support_rcv_01 "RCV Support"
	sum support_rcv_01 
	
	*Difference
	gen support_diff_01 = .
	replace support_diff_01 = support_rcv - support_plurality
	replace support_diff_01 = (support_diff_01+6)/12 
	label var support_diff_01 "RCV-Plurality Support Diff."
	fre support_diff_01
	
*Civility
label def agree 1 "Strongly disagree" 2 "Disagree" 3 "Somewhat disagree" 4 "Neither agree nor disagree" 5 "Somewhat agree" 6 "Agree" 7 "Strongly agree", replace

	*Criticizing
	fre civility_1
	gen civ_crit = . 
	replace civ_crit = 1 if civility_1 == "Strongly disagree"
	replace civ_crit = 2 if civility_1 == "Disagree"
	replace civ_crit = 3 if civility_1 == "Somewhat disagree"
	replace civ_crit = 4 if civility_1 == "Neither agree nor disagree"
	replace civ_crit = 5 if civility_1 == "Somewhat agree"
	replace civ_crit = 6 if civility_1 == "Agree"
	replace civ_crit = 7 if civility_1 == "Strongly agree"
	label var civ_crit "Too Much Criticism"
	label val civ_crit agree 
	fre civ_crit 

	*Negative
	fre civility_2
	gen civ_neg = . 
	replace civ_neg = 1 if civility_2 == "Strongly disagree"
	replace civ_neg = 2 if civility_2 == "Disagree"
	replace civ_neg = 3 if civility_2 == "Somewhat disagree"
	replace civ_neg = 4 if civility_2 == "Neither agree nor disagree"
	replace civ_neg = 5 if civility_2 == "Somewhat agree"
	replace civ_neg = 6 if civility_2 == "Agree"
	replace civ_neg = 7 if civility_2 == "Strongly agree"
	label var civ_neg "Too Negative"
	label val civ_neg agree 
	fre civ_neg 

	*Disrespectful
	fre civility_3
	gen civ_dis = . 
	replace civ_dis = 1 if civility_3 == "Strongly disagree"
	replace civ_dis = 2 if civility_3 == "Disagree"
	replace civ_dis = 3 if civility_3 == "Somewhat disagree"
	replace civ_dis = 4 if civility_3 == "Neither agree nor disagree"
	replace civ_dis = 5 if civility_3 == "Somewhat agree"
	replace civ_dis = 6 if civility_3 == "Agree"
	replace civ_dis = 7 if civility_3 == "Strongly agree"
	label var civ_dis "Too Disrespectful"
	label val civ_dis agree 
	fre civ_dis 

local vars civ_neg civ_crit civ_dis
foreach x of local vars {
	gen `x'_bin = `x'
	replace `x'_bin=(`x'_bin-1)/6
}

label var civ_neg_bin "Too Negative"
label var civ_crit_bin "Too Much Criticism"
label var civ_dis_bin "Too Disrespectful"
sum civ_dis_bin civ_crit_bin civ_neg_bin
alpha civ_crit civ_neg civ_dis, item

	gen civility = .
	replace civility = (civ_dis_bin + civ_crit_bin + civ_neg_bin)/3
	label var civility "Campaign Civility"
	fre civility

*Candidate characteristics
	*Liberal
		*Ideologue (Liberal)
		fre cc_ideologue_l
		gen cc_reps_ideo_l = .
		replace cc_reps_ideo_l = 1 if cc_ideologue_l == "Not at all well"
		replace cc_reps_ideo_l = 2 if cc_ideologue_l == "Not very well"
		replace cc_reps_ideo_l = 3 if cc_ideologue_l == "Somewhat well"
		replace cc_reps_ideo_l = 4 if cc_ideologue_l == "Well"
		replace cc_reps_ideo_l = 5 if cc_ideologue_l == "Very well"
		label def reps_well 1 "Not at all well" 2 "Not very well" 3 "Somewhat well" 4 "Well" 5 "Very well", replace
		label val cc_reps_ideo_l reps_well
		label var cc_reps_ideo_l "Candidate Represents Ideology (Liberal)"
		fre cc_reps_ideo_l	
		
		*Ideology (Liberal)
		fre cc_ideology_l
		gen cc_ideo_l = .
		replace cc_ideo_l = 1 if cc_ideology_l == "Very liberal"
		replace cc_ideo_l = 2 if cc_ideology_l == "Liberal"
		replace cc_ideo_l = 3 if cc_ideology_l == "Somewhat liberal"
		replace cc_ideo_l = 4 if cc_ideology_l == "Moderate"
		replace cc_ideo_l = 5 if cc_ideology_l == "Somewhat conservative"
		replace cc_ideo_l = 6 if cc_ideology_l == "Conservative"
		replace cc_ideo_l = 7 if cc_ideology_l == "Very conservative"
		label val cc_ideo_l conservativism
		label var cc_ideo_l "Candidate Ideology (Liberal)"
		fre cc_ideo_l
		tab cc_ideo_l conservativism 

	*Conservative
		*Ideologue (Conservative)
		fre cc_ideologue_c
		gen cc_reps_ideo_c = .
		replace cc_reps_ideo_c = 1 if cc_ideologue_c == "Not at all well"
		replace cc_reps_ideo_c = 2 if cc_ideologue_c == "Not very well"
		replace cc_reps_ideo_c = 3 if cc_ideologue_c == "Somewhat well"
		replace cc_reps_ideo_c = 4 if cc_ideologue_c == "Well"
		replace cc_reps_ideo_c = 5 if cc_ideologue_c == "Very well"
		label def reps_well 1 "Not at all well" 2 "Not very well" 3 "Somewhat well" 4 "Well" 5 "Very well", replace
		label val cc_reps_ideo_c reps_well
		label var cc_reps_ideo_c "Candidate Represents Ideology (Conservative)"
		fre cc_reps_ideo_c	
		
		*Ideology (Conservative)
		fre cc_ideology_c
		gen cc_ideo_c = .
		replace cc_ideo_c = 1 if cc_ideology_c == "Very liberal"
		replace cc_ideo_c = 2 if cc_ideology_c == "Liberal"
		replace cc_ideo_c = 3 if cc_ideology_c == "Somewhat liberal"
		replace cc_ideo_c = 4 if cc_ideology_c == "Moderate"
		replace cc_ideo_c = 5 if cc_ideology_c == "Somewhat conservative"
		replace cc_ideo_c = 6 if cc_ideology_c == "Conservative"
		replace cc_ideo_c = 7 if cc_ideology_c == "Very conservative"
		label val cc_ideo_c conservativism
		label var cc_ideo_c "Candidate Ideology (Conservative)"
		fre cc_ideo_c
		tab cc_ideo_c conservativism 

	*Combined
		*Ideologue
		gen cc_ideologue = .
		replace cc_ideologue = cc_reps_ideo_l if cc_ideologue == .
		replace cc_ideologue = cc_reps_ideo_c if cc_ideologue == .
		label val cc_ideologue reps_well
		label var cc_ideologue "Candidate Represents Ideology"
		fre cc_ideologue	
		
		gen cc_ideologue01 = .
		replace cc_ideologue01 = (cc_ideologue-1)/4
		label var cc_ideologue01 "Candidate Represents Ideology"
		sum cc_ideologue01 
	
	*Ideology
		gen cc_ideo = .
		replace cc_ideo = cc_ideo_l if cc_ideo == .
		replace cc_ideo = cc_ideo_c if cc_ideo == .
		label val cc_ideo conservativism
		label var cc_ideo "Candidate Ideology (Cons.)"
		fre cc_ideo	
		
		gen cc_ideo01 = .
		replace cc_ideo01 = (cc_ideo-1)/6
		label var cc_ideo01 "Candidate Ideology (Cons.)"
		sum cc_ideo01 

		gen cc_ideo2 = .
		replace cc_ideo2 = 1 if cc_ideo == 4
		replace cc_ideo2 = 2 if cc_ideo == 3 | cc_ideo == 5
		replace cc_ideo2 = 3 if cc_ideo == 2 | cc_ideo == 6
		replace cc_ideo2 = 4 if cc_ideo == 1 | cc_ideo == 7
		label def cc_ideo2 1 "Moderate" 2 "Somewhat Lib./Cons." 3 "Lib./Cons." 4 "V. Lib./Cons.", replace
		label val cc_ideo2 cc_ideo2 
		label var cc_ideo2 "Candidate Ideological Extremism"
		fre cc_ideo2 
		
		*Do they have the same ideology
			*Exact same
			tab cc_ideo conservativism
			tab cc_ideo conservativism, nol
			gen cc_ideo_exact = .
			replace cc_ideo_exact = 1 if cc_ideo == conservativism
			replace cc_ideo_exact = 0 if cc_ideo != conservativism
			label def cc_ideo_exact 1 "Same" 0 "Different"
			label val cc_ideo_exact cc_ideo_exact
			label var cc_ideo_exact "Candidate and Respondent Share Ideology"
			fre cc_ideo_exact 
		
			*Same orientation
			gen cc_ideo_sim = .
			replace cc_ideo_sim = 1 if cc_ideo < 4 & conservativism < 4
			replace cc_ideo_sim = 1 if cc_ideo > 4 & conservativism > 4
			replace cc_ideo_sim = 0 if cc_ideo_sim != 1
			label val cc_ideo_sim cc_ideo_same
			label var cc_ideo_sim "Candidate and Respondent Share Ideology"
			fre cc_ideo_sim 
			
			*Distance
			gen cc_ideo_dist = .
			replace cc_ideo_dist = conservativism - cc_ideo
			label var cc_ideo_dist "Respondent-Candidate Ideological Distance"
			fre cc_ideo_dist 			
			recode cc_ideo_dist (-6/-3=-3) (-2=-2) (-1=-1) (0=0) (1=1) (2=2) (3/6=3), gen(cc_ideo_dist3)
			label var cc_ideo_dist3 "Respondent-Candidate Ideological Distance"
			fre cc_ideo_dist3 
			
			gen cc_ideo_dist01_r = .
			replace cc_ideo_dist01_r = (cc_ideo_dist3+3)/6
			label var cc_ideo_dist01_r "Relative Respondent-Candidate Ideological Distance"
			fre cc_ideo_dist01_r 

			gen cc_ideo_dist01_a = .
			replace cc_ideo_dist01_a = abs(cc_ideo_dist)/6
			label var cc_ideo_dist01_a "Absolute Respondent-Candidate Ideological Distance"
			fre cc_ideo_dist01_a 
			
		*Support
		tab cc_votechoice_c if cc_votechoice_c != ""
		tab cc_votechoice_l if cc_votechoice_l != ""
		
		gen cc_vote = .
		replace cc_vote = 1 if cc_votechoice_c == "Yes"
		replace cc_vote = 1 if cc_votechoice_l == "Yes"
		replace cc_vote = 0 if cc_votechoice_c == "No"
		replace cc_vote = 0 if cc_votechoice_l == "No"
		label var cc_vote "Candidate Support"
		fre cc_vote
		
*Creating measures of affective polarization
	*FTs
		*Using in and out measures
			*AP pre ft
			gen ap_ft_pre = .
			replace ap_ft_pre = pre_ft_cons - pre_ft_lib if conservativism >4
			replace ap_ft_pre = pre_ft_lib - pre_ft_cons if conservativism <4
			replace ap_ft_pre = round(ap_ft_pre, .01)
			label var ap_ft_pre "Diff. Therm"
			sum ap_ft_pre 
			bro pre_ft_cons pre_ft_lib ap_ft_pre
			
			*Ap post ft
			gen ap_ft_post = .
			replace ap_ft_post = post_ft_cons - post_ft_lib if conservativism >4
			replace ap_ft_post = post_ft_lib - post_ft_cons if conservativism <4
			replace ap_ft_post = round(ap_ft_post, .01)
			label var ap_ft_post "AP:FT (Post)"
			sum ap_ft_post 
			
			*Diff between AP pre and post
			gen ap_ft_change = .
			replace ap_ft_change = (ap_ft_post - ap_ft_pre)/2
			label var ap_ft_change "AP:FT ($\Delta$)"
			replace ap_ft_change = round(ap_ft_change, .01)
			sum ap_ft_change 
			
		*Using just out measures
			*AP out party pre
			gen ap_ft_op_pre = .
			replace ap_ft_op_pre = pre_ft_cons if conservativism <4 
			replace ap_ft_op_pre = pre_ft_lib if conservativism >4
			replace ap_ft_op_pre = round(ap_ft_op_pre, .01)
			label var ap_ft_op_pre "Out Therm."	
			sum ap_ft_op_pre 

			*AP out party post
			gen ap_ft_op_post = .
			replace ap_ft_op_post = post_ft_cons if conservativism <4 
			replace ap_ft_op_post = post_ft_lib if conservativism >4
			replace ap_ft_op_post = round(ap_ft_op_post, .01)
			label var ap_ft_op_post "AP:FT, Out-Ideology (Post)"
			sum ap_ft_op_post 	
			
			*Diff between AP out party pre and post
			gen ap_ft_op_change = .
			replace ap_ft_op_change = ap_ft_op_post - ap_ft_op_pre
			replace ap_ft_op_change = round(ap_ft_op_change, .01)
			label var ap_ft_op_change "AP:FT Out-Ideology ($\Delta$)"
			sum ap_ft_op_change 
		
		*Using just in measures
			*AP in party pre
			gen ap_ft_ip_pre = .
			replace ap_ft_ip_pre = pre_ft_cons if conservativism >4 
			replace ap_ft_ip_pre = pre_ft_lib if conservativism <4
			replace ap_ft_ip_pre = round(ap_ft_ip_pre, .01)
			label var ap_ft_ip_pre "In Therm."	
			sum ap_ft_ip_pre 

			*AP in party post
			gen ap_ft_ip_post = .
			replace ap_ft_ip_post = post_ft_cons if conservativism >4 
			replace ap_ft_ip_post = post_ft_lib if conservativism <4
			replace ap_ft_ip_post = round(ap_ft_ip_post, .01)
			label var ap_ft_ip_post "AP:FT, In-Ideology (Post)"
			sum ap_ft_ip_post 	
			
			*Diff between AP in party pre and post
			gen ap_ft_ip_change = .
			replace ap_ft_ip_change = ap_ft_ip_post - ap_ft_ip_pre
			replace ap_ft_ip_change = round(ap_ft_ip_change, .01)
			label var ap_ft_ip_change "AP:FT In-Ideology ($\Delta$)"
			sum ap_ft_ip_change 
			
		/*
		*Rescale 0-1
			*AP change
			sum ap_ft_change
			gen ap_ft_change_01 = (ap_ft_change + abs(r(min)))/(r(max)+ abs(r(min)))
			label var ap_ft_change_01 "AP:FT ($\Delta$)"
			sum ap_ft_change_01 
			bro ap_ft_change_01 

			*AP IP change
			sum ap_ft_ip_change
			gen ap_ft_ip_change_01 = (ap_ft_ip_change + abs(r(min)))/(r(max)+ abs(r(min)))
			label var ap_ft_ip_change_01 "AP:FT In-Ideology (`$\Delta$')"
			sum ap_ft_ip_change_01 
		
			*AP OP change
			sum ap_ft_op_change
			gen ap_ft_op_change_01 = (ap_ft_op_change + abs(r(min)))/(r(max)+ abs(r(min)))
			label var ap_ft_op_change_01 "AP:FT Out-Ideology (`$\Delta$')"
			sum ap_ft_op_change_01 
		*/
	
	*Traits
		*Pre
			*Conservative pre
			gen traits_pre_cons = .
			replace traits_pre_cons = ((pre_t_pat_cons + pre_t_int_cons + pre_t_hon_cons + pre_t_opm_cons + pre_t_gen_cons - (pre_t_hyp_cons + pre_t_slf_cons + pre_t_men_cons))+15)/35
			fre traits_pre_cons
			fre traits_pre_cons if conservativism >4
			fre traits_pre_cons if conservativism <4
			alpha pre_t_pat_cons pre_t_int_cons pre_t_hon_cons pre_t_opm_cons pre_t_gen_cons pre_t_hyp_cons pre_t_slf_cons pre_t_men_cons
			factor pre_t_pat_cons pre_t_int_cons pre_t_hon_cons pre_t_opm_cons pre_t_gen_cons pre_t_hyp_cons pre_t_slf_cons pre_t_men_cons
			
			
			*Liberal pre
			gen traits_pre_lib = .
			replace traits_pre_lib = ((pre_t_pat_lib + pre_t_int_lib + pre_t_hon_lib + pre_t_opm_lib + pre_t_gen_lib - (pre_t_hyp_lib + pre_t_slf_lib + pre_t_men_lib))+15)/35
			fre traits_pre_lib
			fre traits_pre_lib if conservativism >4
			fre traits_pre_lib if conservativism <4
			alpha pre_t_pat_lib pre_t_int_lib pre_t_hon_lib pre_t_opm_lib pre_t_gen_lib pre_t_hyp_lib pre_t_slf_lib pre_t_men_lib
			factor pre_t_pat_lib pre_t_int_lib pre_t_hon_lib pre_t_opm_lib pre_t_gen_lib pre_t_hyp_lib pre_t_slf_lib pre_t_men_lib			
			*Diff pre
			gen ap_traits_pre = .
			replace ap_traits_pre = traits_pre_lib - traits_pre_cons if conservativism <4
			replace ap_traits_pre = traits_pre_cons - traits_pre_lib if conservativism >4
			sum ap_traits_pre
			label var ap_traits_pre "Diff. Traits"
		
			gen op_traits_pre = .
			replace op_traits_pre = traits_pre_lib if conservativism >4
			replace op_traits_pre = traits_pre_cons if conservativism <4
			label var op_traits_pre "Out Traits"

			gen ip_traits_pre = .
			replace ip_traits_pre = traits_pre_lib if conservativism <4
			replace ip_traits_pre = traits_pre_cons if conservativism >4
			label var ip_traits_pre "In Traits"

			*Post
			*Conservative post
			gen traits_post_cons = .
			replace traits_post_cons = ((post_t_pat_cons + post_t_int_cons + post_t_hon_cons + post_t_opm_cons + post_t_gen_cons - (post_t_hyp_cons + post_t_slf_cons + post_t_men_cons))+15)/35
			fre traits_post_cons
			fre traits_post_cons if conservativism >4
			fre traits_post_cons if conservativism <4

			*Liberal post
			gen traits_post_lib = .
			replace traits_post_lib = ((post_t_pat_lib + post_t_int_lib + post_t_hon_lib + post_t_opm_lib + post_t_gen_lib - (post_t_hyp_lib + post_t_slf_lib + post_t_men_lib))+15)/35
			fre traits_post_lib
			fre traits_post_lib if conservativism >4
			fre traits_post_lib if conservativism <4
			
			*Diff post
			gen ap_traits_post = .
			replace ap_traits_post = traits_post_lib - traits_post_cons if conservativism <4
			replace ap_traits_post = traits_post_cons - traits_post_lib if conservativism >4
			sum ap_traits_post
			label var ap_traits_post "AP: Traits (Post)"
			
		*Difference pre-post
			*In ideology
			bro traits_post_cons
			gen ap_traits_ip_change = .
			replace ap_traits_ip_change = traits_post_cons - traits_pre_cons if conservativism >4
			replace ap_traits_ip_change = traits_post_lib - traits_pre_lib if conservativism <4
			sum ap_traits_ip_change
			label var ap_traits_ip_change "AP: Traits, In-Ideology ($\Delta$)"
			
			*Out ideology
			gen ap_traits_op_change = .
			replace ap_traits_op_change = traits_post_cons - traits_pre_cons if conservativism <4
			replace ap_traits_op_change = traits_post_lib - traits_pre_lib if conservativism >4
			sum ap_traits_op_change
			label var ap_traits_op_change "AP: Traits, Out-Ideology ($\Delta$)"
			
			*Both 
			gen ap_traits_change = .
			replace ap_traits_change = (ap_traits_post - ap_traits_pre)/2
			sum ap_traits_change 
			label var ap_traits_change "AP: Traits ($\Delta$)"
			
		/*
		*Rescale 0-1
			sum ap_traits_change
			gen ap_traits_change_01 = (ap_traits_change + abs(r(min)))/(r(max)+ abs(r(min)))
			label var ap_traits_change_01 "AP: Traits ($\Delta$)"
			sum ap_traits_change_01 

			*AP IP change
			sum ap_traits_ip_change
			gen ap_traits_ip_change_01 = (ap_traits_ip_change + abs(r(min)))/(r(max)+ abs(r(min)))
			label var ap_traits_ip_change_01 "AP: Traits, In-Ideology ($\Delta$)"
			sum ap_traits_ip_change_01 
		
			*AP OP change
			sum ap_traits_op_change
			gen ap_traits_op_change_01 = (ap_traits_op_change + abs(r(min)))/(r(max)+ abs(r(min)))
			label var ap_traits_op_change_01 "AP: Traits, Out-Ideology (Diff)"
			sum ap_traits_op_change_01 
		*/
		
		*Individual measures
			*Pre
				gen ap_pre_t_pat = .
				replace ap_pre_t_pat = pre_t_pat_cons - pre_t_pat_lib if conservativism >4
				replace ap_pre_t_pat = pre_t_pat_lib - pre_t_pat_cons if conservativism <4
				label var ap_pre_t_pat "AP: Traits, Patriotic (Pre)"
				fre ap_pre_t_pat
				
				gen ap_pre_t_int = .
				replace ap_pre_t_int = pre_t_int_cons - pre_t_int_lib if conservativism >4
				replace ap_pre_t_int = pre_t_int_lib - pre_t_int_cons if conservativism <4
				label var ap_pre_t_int "AP: Traits, Intelligent (Pre)"
				fre ap_pre_t_int	
				
				gen ap_pre_t_hon = .
				replace ap_pre_t_hon = pre_t_hon_cons - pre_t_hon_lib if conservativism >4
				replace ap_pre_t_hon = pre_t_hon_lib - pre_t_hon_cons if conservativism <4
				label var ap_pre_t_hon "AP: Traits, Honest (Pre)"
				fre ap_pre_t_hon			
				
				gen ap_pre_t_opm = .
				replace ap_pre_t_opm = pre_t_opm_cons - pre_t_opm_lib if conservativism >4
				replace ap_pre_t_opm = pre_t_opm_lib - pre_t_opm_cons if conservativism <4
				label var ap_pre_t_opm "AP: Traits, Optimistic (Pre)"
				fre ap_pre_t_opm			
				
				gen ap_pre_t_gen = .
				replace ap_pre_t_gen = pre_t_gen_cons - pre_t_gen_lib if conservativism >4
				replace ap_pre_t_gen = pre_t_gen_lib - pre_t_gen_cons if conservativism <4
				label var ap_pre_t_gen "AP: Traits, Generous (Pre)"
				fre ap_pre_t_gen		
				
				gen ap_pre_t_hyp = .
				replace ap_pre_t_hyp = pre_t_hyp_cons - pre_t_hyp_lib if conservativism >4
				replace ap_pre_t_hyp = pre_t_hyp_lib - pre_t_hyp_cons if conservativism <4
				label var ap_pre_t_hyp "AP: Traits, Hypocritical (Pre)"
				fre ap_pre_t_hyp		
						
				gen ap_pre_t_slf = .
				replace ap_pre_t_slf = pre_t_slf_cons - pre_t_slf_lib if conservativism >4
				replace ap_pre_t_slf = pre_t_slf_lib - pre_t_slf_cons if conservativism <4
				label var ap_pre_t_slf "AP: Traits, Selfish (Pre)"
				fre ap_pre_t_slf		
								
				gen ap_pre_t_men = .
				replace ap_pre_t_men = pre_t_men_cons - pre_t_men_lib if conservativism >4
				replace ap_pre_t_men = pre_t_men_lib - pre_t_men_cons if conservativism <4
				label var ap_pre_t_men "AP: Traits, Mean (Pre)"
				fre ap_pre_t_men		
			
			*Post
				gen ap_post_t_pat = .
				replace ap_post_t_pat = post_t_pat_cons - post_t_pat_lib if conservativism >4
				replace ap_post_t_pat = post_t_pat_lib - post_t_pat_cons if conservativism <4
				label var ap_post_t_pat "AP: Traits, Patriotic (Post)"
				fre ap_post_t_pat
				
				gen ap_post_t_int = .
				replace ap_post_t_int = post_t_int_cons - post_t_int_lib if conservativism >4
				replace ap_post_t_int = post_t_int_lib - post_t_int_cons if conservativism <4
				label var ap_post_t_int "AP: Traits, Intelligent (Post)"
				fre ap_post_t_int	
				
				gen ap_post_t_hon = .
				replace ap_post_t_hon = post_t_hon_cons - post_t_hon_lib if conservativism >4
				replace ap_post_t_hon = post_t_hon_lib - post_t_hon_cons if conservativism <4
				label var ap_post_t_hon "AP: Traits, Honest (Post)"
				fre ap_post_t_hon			
				
				gen ap_post_t_opm = .
				replace ap_post_t_opm = post_t_opm_cons - post_t_opm_lib if conservativism >4
				replace ap_post_t_opm = post_t_opm_lib - post_t_opm_cons if conservativism <4
				label var ap_post_t_opm "AP: Traits, Optimistic (Post)"
				fre ap_post_t_opm			
				
				gen ap_post_t_gen = .
				replace ap_post_t_gen = post_t_gen_cons - post_t_gen_lib if conservativism >4
				replace ap_post_t_gen = post_t_gen_lib - post_t_gen_cons if conservativism <4
				label var ap_post_t_gen "AP: Traits, Generous (Post)"
				fre ap_post_t_gen		
				
				gen ap_post_t_hyp = .
				replace ap_post_t_hyp = post_t_hyp_cons - post_t_hyp_lib if conservativism >4
				replace ap_post_t_hyp = post_t_hyp_lib - post_t_hyp_cons if conservativism <4
				label var ap_post_t_hyp "AP: Traits, Hypocritical (Post)"
				fre ap_post_t_hyp		
						
				gen ap_post_t_slf = .
				replace ap_post_t_slf = post_t_slf_cons - post_t_slf_lib if conservativism >4
				replace ap_post_t_slf = post_t_slf_lib - post_t_slf_cons if conservativism <4
				label var ap_post_t_slf "AP: Traits, Selfish (Post)"
				fre ap_post_t_slf		
								
				gen ap_post_t_men = .
				replace ap_post_t_men = post_t_men_cons - post_t_men_lib if conservativism >4
				replace ap_post_t_men = post_t_men_lib - post_t_men_cons if conservativism <4
				label var ap_post_t_men "AP: Traits, Mean (Post)"
				fre ap_post_t_men	
	
		*Difference
			gen ap_t_pat = .
			replace ap_t_pat = ap_post_t_pat - ap_pre_t_pat
			label var ap_t_pat "AP: Traits, Patriotic"
			fre ap_t_pat 
	
			gen ap_t_int = .
			replace ap_t_int = ap_post_t_int - ap_pre_t_int
			label var ap_t_int "AP: Traits, Intelligent"
			fre ap_t_int 
		
			gen ap_t_hon = .
			replace ap_t_hon = ap_post_t_hon - ap_pre_t_hon
			label var ap_t_hon "AP: Traits, Honest"
			fre ap_t_hon 	
	
			gen ap_t_opm = .
			replace ap_t_opm = ap_post_t_opm - ap_pre_t_opm
			label var ap_t_opm "AP: Traits, Optimistic"
			fre ap_t_opm 		
	
			gen ap_t_gen = .
			replace ap_t_gen = ap_post_t_gen - ap_pre_t_gen
			label var ap_t_gen "AP: Traits, Generous"
			fre ap_t_gen 		
		
			gen ap_t_hyp = .
			replace ap_t_hyp = ap_post_t_hyp - ap_pre_t_hyp
			label var ap_t_hyp "AP: Traits, Hypocritical"
			fre ap_t_hyp 		
			
			gen ap_t_slf = .
			replace ap_t_slf = ap_post_t_slf - ap_pre_t_slf
			label var ap_t_slf "AP: Traits, Selfish"
			fre ap_t_slf 		
				
			gen ap_t_men = .
			replace ap_t_men = ap_post_t_men - ap_pre_t_men
			label var ap_t_men "AP: Traits, Mean"
			fre ap_t_men 		

		*Rescale
		sum ap_t_pat ap_t_int ap_t_hon ap_t_opm ap_t_gen ap_t_hyp ap_t_slf ap_t_men
		local vars ap_t_pat ap_t_int ap_t_hon ap_t_opm ap_t_gen ap_t_hyp ap_t_slf ap_t_men
		foreach var of local vars {
		sum `var'
		gen `var'_01 = (`var' - r(min)) / (r(max) - r(min))
		}
		sum ap_t_pat_01 ap_t_int_01 ap_t_hon_01 ap_t_opm_01 ap_t_gen_01 ap_t_hyp_01 ap_t_slf_01 ap_t_men_01
		
			*Pre
				label var ap_t_pat_01 "AP: Traits, Patriotic"
				fre ap_t_pat_01
				
				label var ap_t_int_01 "AP: Traits, Intelligent"
				fre ap_t_int_01	
				
				label var ap_t_hon_01 "AP: Traits, Honest"
				fre ap_t_hon_01			
				
				label var ap_t_opm_01 "AP: Traits, Optimistic"
				fre ap_t_opm_01			
				
				label var ap_t_gen_01 "AP: Traits, Generous"
				fre ap_t_gen_01		
				
				label var ap_t_hyp_01 "AP: Traits, Hypocritical"
				fre ap_t_hyp_01		
						
				label var ap_t_slf_01 "AP: Traits, Selfish"
				fre ap_t_slf_01		
								
				label var ap_t_men_01 "AP: Traits, Mean"
				fre ap_t_men_01		
	
*Respondents with issues
fre status
bro if prolific_pid == "66ee0b56c6dc6d0bef12f667"
	*Expcetionally short, unknown code
	
bro if prolific_pid == "6712d7b8642037d9af36ff85"
	*Exceptionally long	
	
*No codes
bro if prolific_pid == "6746681bf6b3a68711f268ad"
	*Finished
	
bro if prolific_pid == "66c22687fc86040228267008"
fre progress if prolific_pid == "66c22687fc86040228267008"
	*Didnt do study
	
bro if prolific_pid == "60aef7d156d2134b8e20d737"
	*Finished

bro if prolific_pid == "67917f653b31981894f4a048"
	*Didnt do study

bro if prolific_pid == "67b7200c877d99ec2bab6dfa"
	
	
bro if prolific_pid == "66d9869a4e9051cdf5d16fa3"
	*Had tech issues
	
bro if prolific_pid == "66444b4139ecba69e9630a90"
		*Had tech issues

*Drop those who did not answer key questions or are 		
drop if ap_ft_change == . | ap_traits_change == .
drop if liberal == 0 &conserv == 0

save "G:\My Drive\Backup 08202022\Working Papers\RCV and Candidate Support\Data and Methods\RCV Candidate Support Data Cleaned.dta", replace